﻿<%@ Page Language="C#" MasterPageFile="~/Layout.Master" AutoEventWireup="true" CodeBehind="showPayments.aspx.cs" Inherits="PT.pages.showPayments" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
<asp:Content ID="cpContent" ContentPlaceHolderID="cpContent" runat="server">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:HotelConnectionString1 %>" 
        
        SelectCommand="SELECT Rooms.name, Reservation.startDate, Reservation.endDate, DATEDIFF(DAY, Reservation.startDate, Reservation.endDate) AS iloscDni, Rooms.cost, DATEDIFF(DAY, Reservation.startDate, Reservation.endDate) * Rooms.cost AS doZaplaty FROM Reservation INNER JOIN Rooms ON Reservation.room_id = Rooms.id">
    </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" BorderStyle="None" 
        CssClass="grid" DataSourceID="SqlDataSource1" Width="100%">
        <Columns>
            <asp:BoundField DataField="name" HeaderText="Nazwa" SortExpression="name" />
            <asp:BoundField DataField="startDate" HeaderText="Początek" 
                SortExpression="startDate" />
            <asp:BoundField DataField="endDate" HeaderText="Koniec" 
                SortExpression="endDate" />
            <asp:BoundField DataField="iloscDni" HeaderText="Liczba dni" 
                SortExpression="iloscDni" />
            <asp:BoundField DataField="cost" DataFormatString="{0} zł" HeaderText="Cena" 
                SortExpression="cost" />
            <asp:BoundField DataField="doZaplaty" DataFormatString="{0} zł" 
                HeaderText="Do zapłaty" ReadOnly="True" SortExpression="doZaplaty" />
        </Columns>
    </asp:GridView>
    <br />
</asp:Content>
